﻿<EditorForm Model="@Model" AutoGenerateAllItem="false">
    <FieldItems>
        <EditorItem @bind-Field="@Model.Name" />
        <EditorItem @bind-Field="@Model.Age" />
        <EditorItem @bind-Field="@Model.Hobby">
            <EditTemplate Context="value">
                @{
                var model = value as Dummy;

                // 此处也可以不使用 Context 值，直接使用模型 ValidateModel 即可
                }
                <div class="form-group col-12">
                    <Select TValue="int" SkipValidate="true" @bind-Value="@DummyId" Items="@DummyItems" ShowSearch="true" DisplayText="选择明细" />
                </div>
                <div class="form-group col-12">
                    <CheckboxList TModel="SelectedItem" TValue="IEnumerable<string>" @bind-Value="@model!.Hobby" Items="@Hobbys"
                                  ValueField="Value" TextField="Text" CheckedField="Active">
                        <RequiredValidator ErrorMessage="至少选择一种爱好" />
                    </CheckboxList>
                </div>
            </EditTemplate>
        </EditorItem>
    </FieldItems>
</EditorForm>

@code {
    private readonly List<SelectedItem> DummyItems = new List<SelectedItem>()
    {
        new SelectedItem("1", "1"),
        new SelectedItem("2", "2"),
        new SelectedItem("3", "3"),
        new SelectedItem("4", "4"),
        new SelectedItem("5", "5")
    };

    private int DummyId = 0;
}
